#define _CRT_SECURE_NO_WARNINGS 1

const int MOD = 1e9 + 7;
const int MX = 1e5;

int pow2[MX];

auto init = [] {
    pow2[0] = 1;
    for (int i = 1; i < MX; i++) pow2[i] = (pow2[i - 1] * 2) % MOD;
    return 0;
    }();
class Solution {
public:
    int numSubseq(vector<int>& nums, int target) {
        sort(nums.begin(), nums.end());
        int right = nums.size() - 1;
        int res = 0;
        for (int left = 0; left < nums.size(); left++)
        {
            while (right >= left && nums[left] + nums[right] > target) --right;
            if (left > right)
                break;
            res = (res + pow2[right - left]) % MOD;
        }
        return res;
    }
};